package com.xiaoshou.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.stereotype.Controller;

import com.xiaoshou.pojo.Lectures;
import com.xiaoshou.pojo.User;

@Controller
@Results({
		@Result(name = "reservationLecturepage", location = "reserlecture.jsp", type = "dispatcher",params={"lecturesList","${lecturesList}"}),
		@Result(name = "saveReserLectureSuccess", location = "index.action", type = "redirectAction") })
public class LectureAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	private Lectures lecture;
	private String hospitalname;
	private List<String> lecturesList;

	@Override
	public String execute() throws Exception {
		return null;
	}

	@Action("toReserLecturePage")
	public String toReserLecture() {
		lecturesList = getUserService().findLucturers();
		
		return "reservationLecturepage";
	}

	@Action("saveReserLecture")
	public String saveLecture() {
		User user = (User) getFromSession("user");
		getLecturesService().saveLectures(user, lecture, hospitalname);
		return "saveReserLectureSuccess";
	}

	// set get
	public Lectures getLecture() {
		return lecture;
	}

	public void setLecture(Lectures lecture) {
		this.lecture = lecture;
	}

	public String getHospitalname() {
		return hospitalname;
	}

	public void setHospitalname(String hospitalname) {
		this.hospitalname = hospitalname;
	}

	public List<String> getLecturesList() {
		return lecturesList;
	}

	public void setLecturesList(List<String> lecturesList) {
		this.lecturesList = lecturesList;
	}

}
